package com.cucn.mms.common.service.Interface.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cucn.mms.common.common.R;
import com.cucn.mms.common.service.Interface.PictureManageService;
import com.cucn.mms.dao.PictureManageMapper;
import com.cucn.mms.domain.PictureManage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
* @author 执念
* @description 针对表【mms_picture_info】的数据库操作Service实现
* @createDate 2023-04-26 23:42:12
*/
@Service
public class PictureManageServiceImpl extends ServiceImpl<PictureManageMapper, PictureManage>
    implements PictureManageService{

    @Autowired
    private PictureManageMapper pictureManageMapper;

    @Override
    public Map<String, Object> selectPictureByType(String keyword, String searchType, int offset, int limit) {
        List<PictureManage> list = pictureManageMapper.selectPictureByType(keyword,searchType,offset,limit);
        return R.success(list,countPicture());
    }

    @Override
    public int countPicture() {
        int total = pictureManageMapper.countPicture();
        return total;
    }

    @Override
    public Map<String, Object> updatePictureRecord(PictureManage pictureManage) {
        boolean b = pictureManageMapper.updatePictureRecord(pictureManage);
        if(b){
            return R.success();
        }
        return R.error();
    }

    @Override
    public Map<String, Object> deletePictureRecord(Integer pictureId) {
        boolean b = pictureManageMapper.deletePictureRecord(pictureId);
        if(b){
            return R.success();
        }
        return R.error();
    }

    @Override
    public Map<String, Object> addPicture(PictureManage pictureManage) {
        pictureManage.setCreateTime(new Date());
        boolean addResult = pictureManageMapper.addPicture(pictureManage);
        if(addResult){
            return R.success();
        }
        return R.error();
    }
}




